package com.tevintao.marketingsystem.task;

import android.view.View;
import android.view.ViewGroup;

import com.tevintao.marketingsystem.log.LogManager;
import com.tevintao.marketingsystem.services.ViewOperation;
import com.tevintao.marketingsystem.xposted.WxTaskManger;


public class ChangeSexTaskProcess extends SetTaskExtra {
    private static ChangeSexTaskProcess ourInstance = new ChangeSexTaskProcess();

    public static ChangeSexTaskProcess getInstance() {
        return ourInstance;
    }

    private ChangeSexTaskProcess() {
    }

    @SuppressWarnings("ResourceType")
    @Override
    public boolean processView(String contextName, View v) {
        if (WxUiViewConfig.MAIN_LAUNCH.equals(contextName)) {
            boolean inContact = WxUiViewConfig.inTab(v, WxUiViewConfig.TAB_ME);
            if (inContact) {
                LogManager.getInstance().logInfo("当前位于我按钮所在的列表");
                View myName = v.findViewById(WxUiViewConfig.MY_NAME_ITEM);
                if (null != myName) {
                    ViewOperation.clickView(myName);
                }
            }
        } else if (WxUiViewConfig.VIEW_ME_INFO.equals(contextName)) {
            View sexView = WxUiViewConfig.getViewByIdAndContent((ViewGroup) v, 16908310, "性别");
            LogManager.getInstance().logInfo("sex view = " + sexView);
            if (null != sexView) {
                ViewOperation.clickView(sexView);
            }
        } else if (WxUiViewConfig.DIALOG_CLASS.equals(contextName)) {
            View sexItem = WxUiViewConfig.getViewByIdAndContent((ViewGroup) v, 2131624011, "女");
            if (null != sexItem) {
                ViewOperation.clickView(sexItem);
                taskError(v.getContext(), WxTaskManger.TASK_SATE_SUCCESS, "选择性别成功 女");
            }
        }
        return false;
    }
}
